import * as actionTypes from './actionTypes'
const defaultState = {
	userInfo: {}, //用户信息
	isOpen: false, //是否展开收藏
	userTabsIndex: '1', //用户中心Tabs的index
	keyword: '', //博客搜索框的值
	homeArticleList: [], //首页文章列表缓存
	homeTopDis: 0, //首页距离顶部的内容
	detailTopDis: 0, // 文章详情页到顶部的距离
	detailObj: {}, // 当前文章详情对象
}
export default (state = defaultState, action) => {
	switch (action.type) {
		case actionTypes.CHANGE_USERINFO:
			return {
				...state,
				userInfo: action.data
			}
		case actionTypes.CHANGE_ISOPEN:
			return {
				...state,
				isOpen: action.data
			}
		case actionTypes.CHANGE_USERTABSINDEX:
			return {
				...state,
				userTabsIndex: action.data
			}
		case actionTypes.CHANGE_KEYWORD:
			return {
				...state,
				keyword: action.data
			}
		case actionTypes.CHANGE_HOMEARTICLELIST:
			return {
				...state,
				homeArticleList: action.data
			}
		case actionTypes.CHANGE_HOMETOPDIS:
			return {
				...state,
				homeTopDis: action.data
			}
		case actionTypes.CHANGE_DETAILTOPDIS:
			return {
				...state,
				detailTopDis: action.data
			}
		case actionTypes.CHANGE_DETAILOBJ:
			return {
				...state,
				detailObj: action.data
			}
		default:
			return state
	}
}